﻿<!-- 管理站配置 -->
<template>
    <div>
        <!-- 添加按钮 -->
        <div class="btn-add">
            <button type="button" class="btn btn-info btn-lg" @click="showdv('0')"><i class="iconfont icon-xinjian ft12 mr5"></i>设置计价类别</button>
            <button type="button" style="display:none" class="btn btn-success btn-lg" @click="showdv('1')"><i class="iconfont icon-chenggong ft12 mr5 "></i>上报状态</button>
        </div>
        <!-- 按条件选择 -->

        <div class="tab-filter-type mt20">
            <div class="oh mt20">
                <h5 class="pull-left tr">全部类型：</h5>
                <ul class="tab-type ft14">
                    <li><span class="active" @click="selzz('')">全部</span></li>
                    <li v-for="item in zzdata"><span @click="selzz(item)">{{item.DeptName}}</span></li>

                </ul>
            </div>
        </div>



        <div class="default-tab ft14  hover-btn" style="overflow-x: inherit;padding:20PX;padding-top:10px">


            <base-table :pzoption="tableop" @selection-change="handleSelectionChange">
            </base-table>
        </div>
        <div class="modal fade dx" id="ZGModal" role="dialog">
            <div class="modal-dialog" role="document" style="width: 1100px">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>

                        <h4 class="modal-title" v-show="type=='1'">
                            设置计价类别
                        </h4>
                        <h4 class="modal-title" v-show="type=='0'">
                            设置上报状态
                        </h4>
                    </div>
                    <div class="modal-body" style="min-height: 100px;text-align: center; margin-top: 50PX;">
                        <el-radio-group v-model="jjlb" v-show="type=='0'">
                            <el-radio :label="0">分类计价</el-radio>
                            <el-radio :label="1">累进加价</el-radio>
                        </el-radio-group>
                        <el-radio-group v-model="sbzg" v-show="type=='1'">
                            <el-radio :label="0">关闭上报</el-radio>
                            <el-radio :label="1">开启上报</el-radio>
                        </el-radio-group>



                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                        <button type="button" class="btn btn-info" @click="SaveData()">确认</button>

                    </div>
                </div>
            </div>
        </div>

        <!-- 表格 -->



    </div>
</template>

<script>
    module.exports = {
        props: ['pdata'],
        components: {
            'base-table': httpVueLoader('/ViewV5/Base/Vue/Table.vue')
        },
        data: function () {
            return {
                zz: "",
                type: "0",
                sbzg: 1,
                jjlb: 1,
                alldata: [],
                zzdata: [],
                DeptCodes: [],
                tableop: {
                    title: "管理站信息",
                    issel: true,
                    iscz: false,
                    height: 500,
                    isxh: true,
                    loading: true,
                    dataset: [],
                    multipleSelection: [],
                    collist: [
                        { colid: "DeptCode", colname: "DeptCode", isshow: false, istip: true },
                        { colid: "DeptName", colname: "管理站", isshow: true, istip: true },
                        { colid: "DeptDesc", colname: "计价类别", isshow: true, istip: true },
                        //{
                        //    colid: "IsHasQX", colname: "是否开启上报", isshow: true, istip: true, rowfun: function (rowdata) {
                        //        if (rowdata.IsHasQX == 'Y') {
                        //            return "<span>已开启</span>";

                        //        } else {
                        //            return "<span  style='color:red;'><i class='el-icon-lock'></i>已关闭</span>";
                        //        }
                        //    }
                        //},
                    ]
                }
            }
        },
        methods: {

            handleSelectionChange(val) {
                this.tableop.multipleSelection = val;
            },
            selzz: function (item) {
                var pro = this;
                if (item) {
                    pro.tableop.dataset = _.filter(pro.alldata, function (obj) {
                        return obj.DeptRoot == item.DeptCode;
                    });
                } else {
                    pro.tableop.dataset = pro.alldata;

                }
            },
            showdv: function (type) {
                var pro = this;
                var DeptCodes = [];
                for (var i = 0; i < pro.tableop.multipleSelection.length; i++) {
                    DeptCodes.push(pro.tableop.multipleSelection[i].DeptCode);
                }
                if (DeptCodes.length == 0) {
                    pro.$notify.error({
                        title: '错误',
                        message: '至少需要选择一条数据才能操作'
                    });
                    return;
                }
                pro.type = type;
                pro.DeptCodes = DeptCodes;
                $('#ZGModal').modal('show');

            },
            SaveData: function () {
                var pro = this;
                var upcontent = "";
                if (pro.type == "1") {
                    if (pro.sbzg == '1') {
                        upcontent = "Y";
                    } else {
                        upcontent = "N";
                    }
                } else {
                    if (pro.jjlb == '0') {
                        upcontent = "分类计价";
                    } else {
                        upcontent = "累进加价";
                    }
                }
                $.getJSON("/api/Bll/ExeAction?Action=SFJS_GLZSET", { P1: pro.DeptCodes.join(), P2: pro.type, upcontent: upcontent },
                    function (resultData) {
                        if (!resultData.ErrorMsg) {
                            $('#ZGModal').modal('hide');
                            pro.$notify({
                                title: '成功',
                                message: '操作成功',
                                type: 'success'
                            });
                            for (var i = 0; i < pro.tableop.multipleSelection.length; i++) {
                                if (pro.type == "1") {
                                    pro.tableop.multipleSelection[i].IsHasQX = upcontent;
                                } else {
                                    pro.tableop.multipleSelection[i].DeptDesc = upcontent;

                                }
                            }
                        }
                    }
                )
            },
            querydata: function () {
                var pro = this;
                pro.tableop.loading = true;
                $.getJSON('/api/Auth/ExeAction?Action=GETALLBMNEW', { P1: pro.zz }, function (resultData) {
                    if (!resultData.ErrorMsg) {
                        pro.zzdata = _.filter(resultData.Result1, function (obj) {
                            return obj.DeptRoot == '1';
                        });
                        pro.alldata = _.filter(resultData.Result1, function (obj) {
                            return obj.Remark2 == 'Y';
                        });
                        pro.tableop.dataset = _.filter(resultData.Result1, function (obj) {
                            return obj.Remark2 == 'Y';
                        });
                        pro.tableop.loading = false;
                        pro.selzz('');

                    }
                })


            },
            InitWigetData: function () {
                this.querydata();
            },
        },
        watch: {

        },
        mounted: function () {
            var pro = this;
            pro.$nextTick(function () {
                pro.InitWigetData();
            })

        }
    };
</script>